package com.smartstate.dataManagement.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smartstate.dataManagement.entity.Energy;
import com.smartstate.dataManagement.vo.EnergyVO;
import com.smartstate.dataManagement.vo.TreeNodeEnergyVO;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface EnergyPanelMapper extends BaseMapper<Energy> {

    /**
     * 获取一天的有功汇总
     * @param startDayStr
     * @return
     */
    @Select("select sum(${typeName}) from half_hour_power_meter_summary where dayStr = #{time}")
    String queryDayType(@Param("time") String startDayStr, String typeName);

    /**
     * 获取typeId集合
     * @return
     */
    @Select("select id from objtype")
    List<String> queryIdByObjtype();


    /**
     * 获取对象组的节点
     * @param type
     * @return
     */
    List<EnergyVO> expression(String type, String parentId);

    /**
     * 获取所有对象组type
     * @return
     */
    @MapKey("id")
    Map<Long, Map<String,Object>> getUserValueMap();

    /**
     * 根据objId查询其对应名称
     * @param oldKey
     * @return
     */
    @Select("select name from objmoudel where id = #{oldKey}")
    String queryNameByObjId(String oldKey);
}
